package com.logistics.log.controller;

import com.logistics.log.entity.model.LogPager;
import com.logistics.log.service.LogService;
import com.logistics.utils.exception.MessageException;
import com.logistics.utils.response.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("sys/log")
public class LogController {

    @Autowired
    private LogService logService;

    /**
     * 分页查询
     * @param param
     * @return
     */
    @PostMapping("pager")
    public ResponseEntity pager(@RequestBody LogPager param){
        return ResponseUtil.success(logService.pager(param));
    }

    /**
     * 查找详细
     * @param id
     * @return
     * @throws MessageException
     */
    @GetMapping("details/{id}")
    public ResponseEntity details(@PathVariable("id") String id) throws MessageException {
        return ResponseUtil.success(logService.details(id));
    }

    /**
     * 删除
     * @param ids
     * @return
     * @throws MessageException
     */
    @DeleteMapping("remove/{ids}")
    public ResponseEntity remove(@PathVariable("ids") String ids) throws MessageException {
        logService.remove(ids);
        return ResponseUtil.success();
    }
}
